﻿/*****************************************************************//**
 * @file    FITKGraphObjectSketch2DPreview.h
 * @brief   Graph object for previewing 2D sketch( with the current construction line ).
 *  
 * @author  ChengHaotian (yeguangbaozi@foxmail.com)
 * @date    2025-01-02
 *********************************************************************/

#ifndef __FITKGRAPHOBJECTSKETCH2DPREVIEW_H__
#define __FITKGRAPHOBJECTSKETCH2DPREVIEW_H__

#include "FITKGraphObject3D.h"

#include "FITKVTKGraphAdaptorAPI.h"

#include <QVector>

// Forward declaration
class vtkPoints;
class vtkUnstructuredGrid;

class FITKGraphActor;

namespace Interface
{
    class FITKAbsGeoSketch2D;
}

namespace Exchange
{
    /**
     * @brief   Graph object for previewing 2D sketch( with the current construction line )..
     * @author  ChengHaotian (yeguangbaozi@foxmail.com)
     * @date    2025-01-02
     */
    class FITKVTKGRAPHADAPTORAPI FITKGraphObjectSketch2DPreview : public FITKGraphObject3D
    {
        // Regist
        FITKGraphObjectRegist(FITKGraphObjectSketch2DPreview, FITKGraphObject3D);
        FITKCLASS(Exchange, FITKGraphObjectSketch2DPreview);

    public:
        /**
         * @brief   Constructor.
         * @param   sketchData: The sketch data object
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2025-01-02
         */
        FITKGraphObjectSketch2DPreview(Interface::FITKAbsGeoSketch2D* sketchData);

        /**
         * @brief   Destructor.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2025-01-02
         */
        ~FITKGraphObjectSketch2DPreview();

        /**
         * @brief   Update all graph actors.[override]
         * @param   forceUpdate: Force update[default]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2025-01-02
         */
        void update(bool forceUpdate = false) override;

        /**
         * @brief   Get the fixed sized bounds of this graph object.[override]
         * @param   The bounds size
         * @return  If the graph object has fixed sized bounds
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2025-01-02
         */
        bool getFixedBounds(double* bounds) override;

    protected:
        /**
         * @brief   Constructor.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2025-01-02
         */
        FITKGraphObjectSketch2DPreview() = default;

    private:
        /**
         * @brief   Initialize.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2025-01-02
         */
        void init();

        /**
         * @brief   Generate the dataset of the sketch.
         * @return  Is OK
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2025-01-02
         */
        bool generateDataSet();

        /**
         * @brief   Generate the shape with the vtkDataSet.[virtual]
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2025-01-02
         */
        void generateGraph();

        /**
         * @brief   Reset all data.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2025-01-02
         */
        void clearData();

    private:
        /**
         * @brief   The actor for the constructions.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2025-01-02
         */
        FITKGraphActor* m_fActorCons{ nullptr };

        /**
         * @brief   The points of the constructions.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2025-01-02
         */
        vtkPoints* m_pointsCons{ nullptr };

        /**
         * @brief   The grid data of constructions.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2025-01-02
         */
        vtkUnstructuredGrid* m_ugridCons{ nullptr };

        /**
         * @brief   The actor for the sketch edges.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2025-01-02
         */
        FITKGraphActor* m_fActorEdge{ nullptr };

        /**
         * @brief   The points of the sketch edges grid data.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2025-01-02
         */
        vtkPoints* m_pointsEdge{ nullptr };

        /**
         * @brief   The grid data of the sketch edges.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2025-01-02
         */
        vtkUnstructuredGrid* m_ugridEdge{ nullptr };

        /**
         * @brief   The actor for the sketch vertice.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2025-01-02
         */
        FITKGraphActor* m_fActorVert{ nullptr };

        /**
         * @brief   The points of the sketch vertice grid data.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2025-01-02
         */
        vtkPoints* m_pointsVert{ nullptr };

        /**
         * @brief   The grid data of the sketch vertice.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2025-01-02
         */
        vtkUnstructuredGrid* m_ugridVert{ nullptr };

        /**
         * @brief   The last shape state.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2025-01-02
         */
        QVariant m_shapeState = QVariant();

        /**
         * @brief   The last number of constructions.
         * @author  ChengHaotian (yeguangbaozi@foxmail.com)
         * @date    2025-01-02
         */
        int m_numCons = -1;

    };
}   // namespace Exchange

#endif // __FITKGRAPHOBJECTSKETCH2DPREVIEW_H__
